<template>
	<view class="content" :style="{background: 'url('+banner+') no-repeat left top / 100% 100%'}">
		<view class="info-box">
			<image class="logo" lazy-load src="/static/logo.png"></image>
			<view class="text">欢迎来到</view>
			<view class="title">欧蒙医学门户</view>
		</view>
		<view class="submit-box">
			<view class="input-box">
				<uni-icons type="person-filled" color="#FFF" size="20"></uni-icons>
				<input class="input" type="text" :placeholder="i18n.user_name"
				 v-model="username" />
			</view>
			<view class="input-box" >
				<uni-icons type="locked-filled" color="#FFF" size="20"></uni-icons>
				<input class="input" type="password" :placeholder="i18n.password" v-model="password" />
			</view>
			<view v-if="logins" class="btn" hover-class="hover" @tap="login">{{i18n.log_in}}</view>
			<!-- <view class="btn-change" hover-class="hover" @tap="changeLogin()">{{i18n.setting_login_model}}</view> -->
		</view>
	</view>
</template>

<script>
	let time = 0;
	let uid = '';
	let pid = '123';
	let pwd = '';
	let phonename = 'ccc';
	import Tips from "@/common/utils/tips.js"
	import {
		istoken
	} from '@/common/utils/auth.js'
	import {
		openWin,
		ajax
	} from '@/common/common.js'
	import {
		Url
	} from "@/common/config.js"
	export default {
		data() {
			return {
				Url,
				focu: false,
				langu: '中文',
				type: "password",
				list: [],
				banner: '/static/login_banner_3.png',
				username: '',
				password: '',
				logins: true,
				das: [],
			}
		},
		computed: {
			i18n() {
				return this.$t('login')
			},
			i18n1() {
				return this.$t('language')
			}
		},
		onLoad() {
			// this.login()
		},
		methods: {
			//登录接口
			login() {
				uid = this.username
				pwd = this.password
				ajax({
					url: '/getToken',
					data: {
						uid: uid,
						password: pwd,
						pid: uid,
						pname: phonename
					},
					method: 'POST',
					success: res => {
						console.log(res)
						this.das = res
						if (res.code == 0) {
							//当前时间
							const timestamp = new Date()
							uni.setStorageSync('token', {
								token: this.das.data,
								expire: timestamp + 1000 * 3600 * 12 * 24,
								expire1: timestamp + 1000 * 3600 * 15 * 24
							})
							uni.setStorageSync('user', {
								uuid: uid,
								username: uid
							})
							//保存用户登录信息
							uni.setStorageSync('login_info', {
								userid: uid,
								password: pwd,
								pid: pid
							})
							this.getuserInfo()
							
						}
					}
				})
			},
			//获取用户信息
			getuserInfo() {
				let res = uni.getStorageSync('login_info')
				console.log(res)
				ajax({
					url: '/api/ApiMpUserController/getByUserId/' + res.userid,
					success: res => {
						console.log(res, "1111")
						if (res.code == 0) {
							this.userInfo = res.data
							uni.setStorageSync("user_info", res.data)
							uni.navigateTo({
								// url: '/pages/form1/process-detail/process-detail'
								url:'/pages/process/index/index'
								// url: '/pages/test/att/att'
							})
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.lang {
		color: #FFFFFF;
		font-size: 30rpx;
	}

	.check {
		margin-left: 15rpx;
	}

	.content {
		height: 100vh;
		width: 100%;
		padding: 0 60rpx 60rpx;
		display: flex;
		flex-flow: column;
		justify-content: center;
		box-sizing: border-box;
		position: relative;

		.info-box {
			display: flex;
			flex-flow: column;
			color: #FFFFFF;
			font-weight: bold;
			margin-top: -400rpx;

			.logo {
				width: 160rpx;
				height: 60rpx;
			}

			.text {
				font-size: 36rpx;
				padding: 15rpx 0 5rpx;
				letter-spacing: 2rpx;
			}

			.title {
				font-size: 50rpx;
				letter-spacing: 5rpx;
			}
		}

		.submit-box {
			display: flex;
			flex-flow: column;
			padding-top: 80rpx;

			.input-box {
				display: flex;
				flex-flow: nowrap;
				background: rgba(255, 255, 255, 0.2);
				border-radius: 70rpx;
				height: 85rpx;
				box-sizing: border-box;
				padding: 20rpx 30rpx;
				align-items: center;
				margin-bottom: 25rpx;

				.icon {
					font-size: 42rpx;
					color: #F1F1F1;
				}

				.icons {
					font-size: 42rpx;
					color: #d1d1d1;
				}

				.input {
					width: 100%;
					color: #FFFFFF;
					font-size: 26rpx;
					padding-left: 10rpx;
					box-sizing: border-box;
				}
			}

			.btn {
				background: #FFFFFF;
				border-radius: 70rpx;
				height: 85rpx;
				line-height: 85rpx;
				text-align: center;
				font-size: 30rpx;
				font-weight: bold;
				color: #333333;
				margin: 60rpx 0 80rpx;
			}

			.btn-change {
				font-size: 26rpx;
				color: #FFFFFF;
				text-align: center;
			}
		}

		.bottom {
			position: fixed;
			bottom: 60rpx;
			left: 0;
			width: 100%;
			text-align: center;
			color: #FFFFFF;
			font-size: 24rpx;
		}
	}
</style>
